home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AOL File Library: 4,401 to 4,500
/
aol-file-protocol-4400-4401-to-4500.zip
/
AOLDLs
/
PDA-Newton Development
/
Newt 3.4 (develop apps,pkgs).sit
/
newt-devenv-34.sit
/
applic2.nwt
< prev
next >
Wrap
Text File
|
1998-01-25
|
6KB
|
223 lines
Notes
{labels: 'NIL, viewFont: 10241} // nil=Unfiled, or specify a folder, e.g., 'Business. remove viewFont for current Styles default
//ERASE! in order to erase existing entries in this folder first
applic2.nwt -- Sloup format
25 Jan 1998
Copyright 1994-98 S. Weyer. All Rights Reserved Worldwide.
To be distributed only with NewtDevEnv
expanded MyApp example using more prototypes
see applic0.nwt or NewtATut for introductory example
(that includes Rotate, info button, about box, help)
see applic2.pkg for Paperback version of this file
see applic3.nwt for same version as applic2.nwt but using
earlier, more direct :addApp, :addStep syntax
----------
MyApp2
//:doObj('buildCO,'MyApp2)
//:doObj('add,'MyApp2)
//:doObj('remove,'MyApp2)
{_proto: protoApp,
title: "Hello World -- on Steroids",
_package: {shortTitle: "Hello2"},
}
----------
MyApp2.protoNumberInputLine
{_proto: protoInputLine,
text: "enter a number",
value: 0,
viewFlags: 10753, //vVisible + vClickable + vGesturesAllowed + vNumbersAllowed
viewChangedScript: func(slot,view)
if slot='text
then begin
value := StringToNumber(text);
if not value then value := 0;
if aTotal exists then aTotal:update();
end,
viewSetupFormScript: func()
begin
self.text := clone(text);
self.value := 0;
inherited:?viewSetupFormScript();
end,
}
----------
MyApp2+float
{_proto: protoFloatNGo,
viewBounds: RelBounds(20,50,150,90),
}
----------
MyApp2.float+aboutText
{viewclass: clParagraphView,
text: "This wonderful application from the \"kitchen sink school of user interface design\" created by "&
:GetUserConfig('name) & // the developer's name
", with the help of Newt, the lizard wizard",
viewFlags: 3, //vReadOnly+vVisible,
viewBounds: RelBounds(5,5,140,80), // relative to aFloat
}
----------
MyApp2+button
{_proto: protoTextButton,
text: "About",
viewBounds: RelBounds(20,30,40,16),
buttonClickScript: func()
if float exists
then float:open()
else PlaySound(@102), // ROM_funbeep
}
----------
MyApp2+num1
{_proto: protoNumberInputLine, // use user prototype defined in app
text: "first number", // needs to be set so protos don't share text string
viewBounds: RelBounds(130,20,100,20),
}
----------
MyApp2+num2
{_proto: protoNumberInputLine,
text: "second number",
viewBounds: RelBounds(130,45,100,20),
}
----------
MyApp2+aTotal
{_proto: protoStaticText,
text: "Total",
vars: ['num1, 'num2,], // same names as two fields
viewBounds: RelBounds(130,80,100,16),
update: func()
begin
local tot := 0, field;
foreach field in vars // add up num1.value+num2.value etc.
do tot := tot + GetVariable(self,field).value;
if round exists and round.viewValue
then tot := RIntToL(tot);
SetValue(self,'text,NumberStr(tot));
end,
}
----------
MyApp2+round
{_proto: protoRCheckbox, // checkbox on right & text on left
text: "Round?",
indent: 40,
viewBounds: RelBounds(10,78,50,16),
valueChanged: func() aTotal:update(),
}
----------
MyApp2+aTextval
{_proto: protoStaticText,
text: "xxx",
viewBounds: RelBounds(150,240,100,16),
}
----------
MyApp2+labelLine
{_proto: protoLabelInputLine,
viewBounds: RelBounds(10,110,200,20),
label: "a label",
textSetup: func() clone("some string"), // initial value
labelCommands: ["A", "B", "C"], // optional
textChanged: func()
SetValue(aTextval,'text,entryLine.text),
}
----------
MyApp2+picker
{_proto: protoLabelPicker,
text: "picker",
viewBounds: RelBounds(10,140,100,16),
labelCommands: ["one", "two", "three",],
labelActionScript: func(cmd)
SetValue(aTextval,'text,labelCommands[cmd]),
}
----------
MyApp2+slider
{_proto: protoSlider,
viewBounds: RelBounds(10,160,100,12),
minValue: 1,
maxValue: 3,
viewSetupFormScript: func()
viewValue := (maxValue+minValue)/2,
changedSlider: func()
SetValue(aTextval,'text,NumberStr(viewValue)),
}
----------
MyApp2+radiobuttons
{_proto: protoRadioCluster,
viewBounds: RelBounds(150,190,100,50),
clusterChanged: func()
SetValue(aTextval,'text,NumberStr(clusterValue)),
}
----------
MyApp2.radiobuttons+ten
{_proto: protoRadioButton,
text: "diez",
buttonValue: 10,
viewBounds: RelBounds(0,0,60,15), // relative to radiobuttons
}
----------
MyApp2.radiobuttons+twenty
{_proto: protoRadioButton,
text: "veinte",
buttonValue: 20,
viewBounds: RelBounds(0,15,60,15),
}
----------
MyApp2.radiobuttons+thirty
{_proto: protoRadioButton,
text: "treinta",
buttonValue: 30,
viewBounds: RelBounds(0,30,60,15),
}
----------
MyApp2+textlist
{_proto: protoTextlist,
viewBounds: Relbounds(150,140,60,40),
viewSetupFormScript: func()
begin
self.listItems := ["larry","moe","curly"];
//viewLines := length(listItems);
:setupList() ;
inherited:?viewSetupFormScript();
end,
viewLines: 3,
buttonClickScript: func(i)
SetValue(aTextval,'text,listitems[i]),
}
----------
MyApp2+expando
{_proto: protoExpandoShell,
viewBounds: RelBounds(10,185,120,70),
numLines: 2,
viewFormat: 337, // vfFillWhite+vfFrameBlack+vfPen=1
editHeight: 46, // height of expanded field
editWidth: 80,
indent: 50, // left edge of value
myExpandoProto:
{_proto: protoTextExpando,
label: "a label",
path: 'var,
},
viewSetupFormScript: func()
begin
local i, symslot;
self.target := self;
self.lines:=array(numLines,nil);
for i:=1 to numLines
do begin
symslot := intern("var"&i);
lines[i-1]:=
{_proto: myExpandoProto,
label: "Field" && i,
path: symslot, // e.g., 'var1
};
SetValue(self,symslot,clone(""));
end;
inherited:viewSetupFormScript();
end,
FlushEdits: func() nil, //inherited:?FlushEdits(), // no method to inherit?
CloseEdit: func(view) // expanded field just closed
SetValue(aTextval,'text, target.(view.path)),
}
----------
BYE!